package testPureMvc.components {
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;

	/**
	 * @author Admin
	 */
	public class MainScreen extends MovieClip {
		
		private var _clickRect : MovieClip = new MovieClip();
		
		// Constructor
		public function MainScreen() 
		{
			trace("MainScreen init...");
			addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
		}
		
		private function addedToStageHandler(evt : Event) : void
		{
			trace("MainScreen addedToStage");
			drawRect();
		}
		
		private function drawRect() : void
		{
			trace("MainScreen drawing _clickRect ...");
			_clickRect.graphics.beginFill(0x000000, 1);
			_clickRect.graphics.drawRect(-27, -27, 54, 54);
			_clickRect.graphics.endFill();
			_clickRect.x = 300;
			_clickRect.y = 127;
			_clickRect.rotation = 45;
			addChild(_clickRect);
			_clickRect.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler);
			_clickRect.addEventListener(MouseEvent.MOUSE_UP, clickHandler);
		}
		
		private function clickHandler(e : MouseEvent) : void 
		{
			switch (e.type)
			{
				case MouseEvent.MOUSE_DOWN:
					// do something
					trace("Mouse down!");
					break;
				case MouseEvent.MOUSE_UP:
					trace("Mouse up!");
					// do something
					break;
			}
		}
		
		
		
		
		
	}
}
